/**
 * Created by Administrator on 17-7-28.
 */
 var ss, bb; //获取 选择 的时间范围
 //要传的值
 var sendDtate = {
 	regDateMin: "",
 	regDateMax: "",
 	loginDateMin: "",
 	loginDateMax: "",
 	pro: "",
 	city: "",
 	member_status: "",
 	member_level: ""
 };

 //女生 时间范围选择
 var timestamp = new Date().getTime();
 var torday7 = timestamp - 604800000; //  当前时间的7天前
 var startDate = "";
 var endDate = "";
 var num_sendData = {};
 
 function fmtDate(obj) {
 	var date = new Date(obj);
 	var y = 1900 + date.getYear();
 	var m = "0" + (date.getMonth() + 1);
 	var d = "0" + date.getDate();
 	return y + "-" + m.substring(m.length - 2, m.length) + "-" + d.substring(d.length - 2, d.length);
 }
 var dateRange2 = new pickerDateRange('date4', {
 	isTodayValid: true,
 	startDate: fmtDate(torday7),
 	endDate: fmtDate(timestamp),
 	startToday: false,
 	stopToday: true,
 	needCompare: false,
 	defaultText: ' 至 ',
 	autoSubmit: true,
 	inputTrigger: 'input_trigger4',
 	theme: 'ta',
 	success: function(obj) {
 
 		$("#dCon2").html('开始时间 : ' + obj.startDate + '<br/>结束时间 : ' + obj.endDate);
 	}
 
 });





		// 女生 columns
	var NanGL_columns = [

		{
			data: "reg_date",
			bSortable: true
		}, //注册时间
		{
			data: "login_time",
			bSortable: true
		}, //最近登录时间
		{
			data: function(obj) { // 登录地址
				var str = obj.province + "  " + obj.city;
				return "<span>" + str + "</span>"
			},
			bSortable: false
		},
		{
			data: function(obj) { //头像
				$headImg = "";
				var ssb = obj.head_img.length;

				if(ssb > 50) {
					return "<a href='Javascript:;' class='userData' data-toggle='modal' data-target='#myModal500'><img  width='100px' class='Gl_touxiang' height='100px' src='" + obj.head_img + "'/><small  class='users-id' style='display:none'>g" + obj.girl_id + "</small></a>";
				} else {
					return "<a href='Javascript:;' class='userData' data-toggle='modal' data-target='#myModal500'><img  width='100px' class='Gl_touxiang' height='100px' src='img/head/2014.jpg' alt='没头像'/><small class='users-id' style='display:none'>g" + obj.girl_id + "</small></a>";
				}

			},
			bSortable: false
		},
		{
			data: "nick",
			bSortable: false
		}, //昵称
		{
			data: "account",
			bSortable: false
		}, //手机
		{
			data: function(obj) { //状态  show_status
				var stue = obj.show_status;
				var stue1;
				if(stue == 0 || stue == 1) {stue1 = "普通"}if(stue == 2) {stue1 = "置顶"}if(stue == 3) {stue1 = "屏蔽"}if(stue == 4) {stue1 = "拉黑"}
				return "<span>" + stue1 + "</span>"
			},
			bSortable: false
		},
		{
			data: function(obj) { //会员等级  member_level	
				var strr = obj.member_level;
				var strr1;
				if(strr == 1){strr1 = "非会员"}
				if(strr == 2){strr1 = "普通会员"}if(strr == 3){strr1 = "黄金会员"}if(strr == 4){strr1 = "铂金会员"}if(strr == 5){strr1 = "钻石会员"}
				return "<span>" + strr1 + "</span>"
			},
			bSortable: false
		},

		{
			data: "login_count",
			bSortable: false
		},
		{
			data: "is_vip", // vip
			bSortable: false

		}

	];
	
	
	var selTime;
	//女生数据
	  $(".NvshenGuanli").unbind("click").on("click",function(){
	  	//获取数据
	  	$(".Quanbu").eq(5).css({"display":"block"}).siblings().css({"display":"none"});
	  	var getStime = function getStime() {
	  		var selc_time = $("#select-time1  option:selected").text(); //获取注册或是登录查询
	  		return selc_time
	  	}
	  	var getPtime = function getPtime() {
	  		var pro = $("#ctyi-content1  option:selected").text(); //获取省级选中的值
	  		return pro
	  	}
	  	$("#ctyi-content1 option").eq(0).attr("selected", true);
	  	var getCtime = function getCtime() {
	  		var ctiyx = $("#ctye-municipal1  option:selected").text(); //获取 市级选中的值
	  		return ctiyx
	  	}
	  	$("#ctye-municipal1").empty().append("<option value='" + 9999 + "'>请选择城市</option>");
	  	var getZtime = function getZtime() {
	  		var stutter = $("#studus-content1  option:selected").text(); //获取 状态选中的值
	  		return stutter
	  	}
	  	$("#studus-content1  option").eq(0).attr("selected", true);
	  	var getVtime = function getVtime() {
	  		var vipselc = $("#vip-selec1  option:selected").text(); //获取 状态选中的值
	  		return vipselc
	  	}
	  	$("#vip-selec1  option").eq(0).attr("selected", true);
	
	  	
	  	//城市 二级联动
	  	$.ajax({
	  		url: "allprovinces.json", //json文件位置
	  		type: "GET", //请求方式为get
	  		dataType: "json", //返回数据格式为json
	  		success: function(result) { //返回数据根据结果进行相应的处理 
	  			//		console.log(result)
	  			var len = result.provincesList;
	  			var optio = "";
	  			for(var i = 0; i < len.length; i++) {
	  				optio += "<option value='" + i + "'>" + len[i].Name + "</option>"
	  			}
	  			$("#ctyi-content1").append(optio);
	  			//省级改变
	  			$("#ctyi-content1").unbind('change').on('change',function(){
	  				var optione = "";
	  				var slec = getPtime();
	  				if(slec == "全部") {
	  					sendDtate.pro = "";
	  					sendDtate.city = "";
	  					Data_table("#example5", address1 + "/admin/girl/index", NanGL_columns, true, sendDtate);
	  				} else {
	  					sendDtate.pro = slec;
	  					sendDtate.city = "";
	  					Data_table("#example5", address1 + "/admin/girl/index", NanGL_columns, true, sendDtate);
	  				}
	  				
	  				console.log(sendDtate)
	  				
	  				var item = $(this).val();
	  				if(item == 9999) {
	  					$("#ctye-municipal1").empty().append("<option value='" + 9999 + "'>请选择城市</option>");
	  					return
	  				}
	  				// 二级城市
	  				var lenn = result.provincesList[item].Citys;
	  				for(var j = 0; j < lenn.length; j++) {
	  					optione += "<option value='" + i + "'>" + lenn[j].Name + "</option>"
	  				}
	  				var deful = "<option>请选择</option>";
	  				$("#ctye-municipal1").empty().append(deful + optione);
	  			})
	  		},
	  		error: function(rel) {
	  			console.log("yich")
	  		}
	  	});
	  	// 市级改变
	  	$("#ctye-municipal1").unbind("change").on("change",function(){
	  		var slec2 = getCtime();
	  		
	  		if(slec2 == "请选择") {
	  			sendDtate.city = "";
	  			Data_table("#example5", address1 + "/admin/girl/index", NanGL_columns, true, sendDtate);
	  		} else {
	  			sendDtate.city = slec2;
	  			Data_table("#example5", address1 + "/admin/girl/index", NanGL_columns, true, sendDtate);
	  		}
	  		console.log(sendDtate)
	  	});
	  	//状态改变
	  	$("#studus-content1").unbind('change').on('change',function(){
	  		var slec = getZtime();
	  		if(slec == "全部") {
	  			sendDtate.member_status = "";
	  			Data_table("#example5", address1 + "/admin/girl/index", NanGL_columns, true, sendDtate);
	  		} else {
	  			var slec0 = "";
	  			if(slec == "普通") {
	  				slec0 = 1
	  			}
	  			if(slec == "置顶") {
	  				slec0 = 2
	  			}
	  			if(slec == "屏蔽") {
	  				slec0 = 3
	  			}
	  			if(slec == "拉黑") {
	  				slec0 = 4
	  			}
	  			sendDtate.member_status = slec0;
	  			Data_table("#example5", address1 + "/admin/girl/index", NanGL_columns, true, sendDtate);
	  		}
	  	});
	  	// 会员状态改变
	  	$("#vip-selec1").unbind("change").on("change",function(){
	  		var selec = getVtime();
	  		if(selec == "全部") {
	  			sendDtate.member_level = "";
	  			Data_table("#example5", address1 + "/admin/girl/index", NanGL_columns, true, sendDtate);
	  		} else {
	  			var selec0 = $(this).val();
	  			sendDtate.member_level = selec0;
	  			Data_table("#example5", address1 + "/admin/girl/index", NanGL_columns, true, sendDtate);
	  		}
	  	});
	  	

	  	
	  	$("#date4").unbind('DOMNodeInserted').bind("DOMNodeInserted", function(e) {
	  		var s = $(e.target).text();
	  		ss = s.substr(0, 10);
	  		bb = s.substr(13, 22);
	  		if($("#select-time1  option:selected").text() == "注册时间查询") {
	  	
	  			sendDtate.regDateMin = ss;
	  			sendDtate.regDateMax = bb;
	  	
	  			Data_table("#example5", address1 + "/admin/girl/index", NanGL_columns, true, sendDtate);
	  
	  		}
	  		if($("#select-time1  option:selected").text() == "登录时间查询") {
	  	
	  			sendDtate.loginDateMin = ss;
	  			sendDtate.loginDateMax = bb;
	  	
	  			Data_table("#example5", address1 + "/admin/girl/index", NanGL_columns, true, sendDtate);

	  		}
	  	
	  	});
	  	//点击选择范围
	  	$("#select-time1").unbind('change').on('change',function(){
	  		var slec2 = getStime();
	  		
	  		if(slec2 == "注册时间查询") {
	  			sendDtate.regDateMin = ss;
	  			sendDtate.regDateMax = bb;
	  			sendDtate.loginDateMin = sendDtate.loginDateMax = "";
	  			Data_table("#example5", address1 + "/admin/girl/index", NanGL_columns, true, sendDtate);
	  			$("#date4").unbind("DOMNodeInserted").bind("DOMNodeInserted", function(e) {
	  				var s = $(e.target).text();
	  				ss = s.substr(0, 10);
	  				bb = s.substr(13, 22);
	  				sendDtate.regDateMin = ss;
	  				sendDtate.regDateMax = bb;
	  				sendDtate.loginDateMin = sendDtate.loginDateMax = "";
	  		
	  				Data_table("#example5", address1 + "/admin/girl/index", NanGL_columns, true, sendDtate);
	  		
	  			});
	  		}
	  		if(slec2 == "登录时间查询") {
	  			sendDtate.regDateMin = "";
	  			sendDtate.regDateMax = "";
	  			sendDtate.loginDateMin = ss
	  			sendDtate.loginDateMax = bb;
	  		
	  			Data_table("#example5", address1 + "/admin/girl/index", NanGL_columns, true, sendDtate);
	  			$("#date4").unbind("DOMNodeInserted").bind("DOMNodeInserted", function(e) {
	  				var s = $(e.target).text();
	  				ss = s.substr(0, 10);
	  				bb = s.substr(13, 22);
	  				sendDtate.regDateMin = "";
	  				sendDtate.regDateMax = "";
	  				sendDtate.loginDateMin = ss
	  				sendDtate.loginDateMax = bb;
	  				Data_table("#example5", address1 + "/admin/girl/index", NanGL_columns, true, sendDtate);
	  		
	  			});
	  		}
	  	});
	  	Data_table("#example5", address1 + "/admin/girl/index", NanGL_columns, true);
	  });
	  
	  


	function stopBubbling(e) {
		e = window.event || e;
		if(e.stopPropagation) {
			e.stopPropagation(); //阻止事件 冒泡传播
		} else {
			e.cancelBubble = true; //ie兼容
		}
	}

